﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace FindPath
{
    public partial class PetDetail : UserControl
    {
        private string _name;
        private byte _level;
        private int _curHp;
        private int _maxHp;
        private int _curSp;
        private int _maxSp;
        private int _curExp;
        private int _maxExp;
        private PlayerItem[] _petClothes;
        private bool _isActive = false;
        public string petName { 
            get {
                return _name;
            } 
            set {
                txtPetName1.Text = value;
                _name = value;
        }}
        public byte petLevel {
            get
            {
                return _level;
            }
                 
            set {
                lblDetailLvlPet1.Text = value + "";
                _level = value;
        }}
        public int petCurHp {
            get
            {
                return _curHp;
            }
            set {
                lblDetailCurHpPet1.Text = value + "";
                _curHp = value;
        }}
        public int petMaxHp {
            get
            {
                return _maxHp;
            }
            set {
                lblDetailMaxHpPet1.Text = "/ " + value + "";
                _maxHp = value;
        }}
        public int petCurSp {
            get
            {
                return _curSp;
            }
            set {
                lblDetailCurSpPet1.Text = value + "";
                _curSp = value;
        }}
        public int petMaxSp {
            get
            {
                return _maxSp;
            }
            set
            {
                lblDetailMaxSpPet1.Text = "/ " + value + "";
                _maxSp = value;
            }
        }
        public int petCurExp {
            get
            {
                return _curExp;
            }
            set
            {
                lblDetailCurExpPet1.Text = value + "";
                _curExp = value;
            }
        }
        public int petMaxExp {
            get
            {
                return _maxExp;
            }
            set
            {
                lblDetailMaxExpPet1.Text = "/ " + value + "";
                _maxExp = value;
            }
        }
        public string intStt
        {
            get
            {
                return "";
            }
            set
            {
                lblDetailIntPet1.Text = value;
            }
        }
        public string atkStt
        {
            get
            {
                return "";
            }
            set
            {
                lblDetailAtkPet1.Text = value;
            }
        }

        public string defStt
        {
            get
            {
                return "";
            }
            set
            {
                lblDetailDefPet1.Text = value;
            }
        }
        public string hpxStt
        {
            get
            {
                return "";
            }
            set
            {
                lblDetailHpxPet1.Text = value;
            }
        }
        public string spxStt
        {
            get
            {
                return "";
            }
            set
            {
                lblDetailSpxPet1.Text = value;
            }
        }
        public string agiStt
        {
            get
            {
                return "";
            }
            set
            {
                lblDetailAgiPet1.Text = value;
            }
        }
        public string faiStt
        {
            get
            {
                return "";
            }
            set
            {
                lblDetailFaiPet.Text = value;
            }
        }
        public PlayerItem[] petClothes
        {
            get
            {
                return _petClothes;
            }
            set
            {
                _petClothes = new PlayerItem[6];
                System.Array.Copy(value, _petClothes, 6);
                lstClothesPet1.Items.Clear();
                foreach (PlayerItem item in _petClothes)
                {
                    ListViewItem clothesItem = new ListViewItem("");
                    if (item != null)
                    {
                        clothesItem = new ListViewItem(item.name);
                        clothesItem.SubItems.Add(item.wearLvl.ToString());
                    }
                    lstClothesPet1.Items.Add(clothesItem);
                }
            }
        }
        public bool IsActive
        {
            get
            {
                return _isActive;
            }
            set
            {
                _isActive = value;
                if (_isActive)
                {
                    btnActivePet1.Text = "Rest";
                }
                else
                {
                    btnActivePet1.Text = "Go";
                }
            }
        }
        public delegate void EventHandler(object senders, EventArgs args);
        public event EventHandler ActivePet;
        public PetDetail()
        {
            _petClothes = new PlayerItem[6];
            InitializeComponent();
            
        }

        protected void OnActivePet_Clicked(object sender, EventArgs args)
        {
            if (ActivePet != null)
            {
                ActivePet(sender, args);
            }
        }
        

        private void lstClothesPet1_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {

            }
            else if (e.Button == MouseButtons.Left)
            {
            }
        }

        private void btnActivePet1_Click(object sender, EventArgs e)
        {
            OnActivePet_Clicked(sender, e);
        }

        public void disableActive()
        {
            btnActivePet1.Enabled = false;
            lstClothesPet1.Enabled = false;
        }

        public void enableActive()
        {
            btnActivePet1.Enabled = true;
            lstClothesPet1.Enabled = true;
        }

        public void reset()
        {
            this.petLevel = 0;
            this.petName = "";
            this.petCurHp = 0;
            this.petMaxHp = 0;
            this.petCurSp = 0;
            this.petMaxSp = 0;
            this.petCurExp = 0;
            this.petMaxExp = 0;
            this.atkStt = "0";
            this.intStt = "0";
            this.defStt = "0";
            this.agiStt = "0";
            this.hpxStt = "0";
            this.spxStt = "0";
            this.faiStt = "0";
        }
    }
}
